<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('短信管理列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>平台：</label>
                                <select class="form-control" name="platform">
                                    <option value="">所有</option>
                                    <option value="DANMI">旦米</option>
                                    <option value="DAHAN">大汉</option>
                                    <option value="WOLIAN">沃联</option>
                                    <option value="MIAOXIN">秒信</option>
                                </select>
                            </li>
                            <li>
                                <label>操作类型：</label>
                                <select class="form-control" name="otype">
                                    <option value="">所有</option>
                                    <option value="0">登陆</option>
                                    <option value="1">机构进量通知</option>
                                    <option value="2">客户匹配通知</option>
                                </select>
                            </li>
                            <li>
                                <label>应用类型：</label>
                                <select class="form-control" name="appCode">
                                    <option value="">所有</option>
                                    <option value="rxh">任信花</option>
                                    <option value="bbd">帮帮贷</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>


            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('sys:template:edit')}]];
        var removeFlag = [[${@permission.hasPermi('sys:template:remove')}]];
        var prefix = ctx + "sys/template";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "短信管理",
                columns: [
                //     {
                //     checkbox: true
                // },
                {
                    field: 'otype',
                    title: '操作类型'
                },
                {
                    field: 'platform',
                    title: '短信平台'
                },
                {
                    field: 'appCode',
                    title: 'app类型'
                },
                {
                    field: 'smsSign',
                    title: '短信签名'
                },
                // {
                //     field: 'templateId',
                //     title: '短信模版id'
                // },
                    {
                        field: 'status',
                        title: '状态',
                        formatter: function (value, row, index) {
                            return statusTools(row);
                        }
                    } ,
                    {
                    field: 'templateContext',
                    title: '短信模版内容',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                }

                // ,
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.otype + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.otype + '\')"><i class="fa fa-remove"></i>删除</a>');
                //         return actions.join('');
                //     }
                // }
                ]
            };
            $.table.init(options);
        });


        /* 用户状态显示 */
        function statusTools(row) {
            if (row.status == 0) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\',\'' + row.otype + '\', \'' + row.platform + '\', \'' + row.appCode + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\")"></i> ';
            }
        }

        /* 用户管理启用 */
        function enable(id, otype, platform, appCode) {
            $.modal.confirm("确认要启用["+otype+"]["+platform+"]["+appCode+"]吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id});
            })
        }

    </script>
</body>
</html>